#ifndef _XMOVIEPLAYER_H
#define _XMOVIEPLAYER_H

#include <QObject>
#include <qtimer.h>
#include "xfiforeadthread.h"

class XMoviePlayer : public QObject
{
	Q_OBJECT

public:
	XMoviePlayer(QObject *parent=0);
	~XMoviePlayer();
	void playMovie(const char* file,const int timeout, const int m_index);  //for picture
	void playMovie(const char* file, const int m_index);  // for video
	void stopPlay();    //normally for video
	void setPlayerGeometry(const int x, const int y, const int width, const int height);

protected:
	void initializeFIFO(void);
	void sendCmdToFIFO(const int in_cmdType, const char* in_cmdMsg);
	void clearPicutreConnection();
	void clearVideoConnection();

signals:
	void sgPlayMovieDone(int index);   // notify XInfomatLayoutManager to update playlist
	void sgCPlayerIdle();       	   // notify XInfomatLayoutManager that the cplayer is stop

public slots:
	void onPlayPictureDone(); // respone to QTimer
	void onFinishPicture();
    void onPlayVideoDone();   // respone to XFifoReadThread
	void onStopEnd();

private:
	enum ECommand {
		EStop,
		EOpen,
		EGeometry,
	};
    bool    m_isStop;   //control stop commands
	int  	m_fdIn, m_fdOut;
	QTimer  m_tmPicture;
	XFifoReadThread *m_xFifoRead;
	int    	m_picIndex, m_videoIndex;
	int     m_timeout;
	bool  	m_isCPlayerRunning;
	bool    m_isIdle;
	bool    m_hasSentStop;
};
#endif
